
#ifndef _FLIGHTRECORD_H_20111124
#define _FLIGHTRECORD_H_20111124

#include <string>
#include "Record.h"
#include "TimeDate.h"

namespace AirlineRes
{

/// Class to store and operate upon the data that comprises a flight.
class FlightRecord : public Record
{
public:
  FlightRecord(){};
  ~FlightRecord(){};

  /// Construct record initialised with field values.
  FlightRecord
    (
      std::string const&  _flightCode,
      int         const&  _numSeats,
      TimeDate    const&  _time, 
			std::string const& _destination
    );

  virtual RecordIOResult LoadRecord( std::istream& _stream );
  virtual RecordIOResult WriteRecord( std::ostream& _stream ) const;

  /// Attempts to load in the data that comprises a FlightRecord.
  ///
  /// The function will fail either when the supplied data is in an invalid format, or
  /// if the data fails any sanity check, e.g. the flight date month > 12. If failure 
  /// occurs then the FlightRecord object will be in an undefined state.
  ///
  /// @param _flightCode  String containing the flight code, e.g. "BA123".
  /// @param _numSeats    The number of seats on the flight.
  /// @param _timeOfDay   String containing the 24-hour time of the flight, e.g. "1750".
  /// @param _date        String containing the flight date in ddmmyyyy format, e.g. "12012011"
  /// @param _destination String containing the destination of the flight
	///
  /// @return  A RecordIOResult to indicate success or failure.
  RecordIOResult LoadRecordData( std::string const& _flightCode, int const _numSeats, std::string const& _timeOfDay, std::string const& _date, std::string const& _destination );

  /// Prints this FlightRecord as a line in the specified stream.
  ///
  /// @param _stream  Output stream to insert into.
  ///
  /// @return  A RecordIOResult indicating whether or not the operation was a success.
  RecordIOResult PrintRecordData( std::ostream& _stream ) const;

  /// @return  The number of seats on the flight.
  int GetNumSeats() const { return m_numSeats; };
  /// @return  The flight code.
  std::string GetFlightCode() const { return m_flightCode; };
/// @return time and date of the flight.
  TimeDate GetFlightTimeDate() const { return m_time; };	/// @return The destination
	std::string GetDestination() const { return m_destination; };

private:
  // Sanity check constants for use by LoadRecordData.
  static int const sc_numSeatsMax = 1000;

  static int const sc_dateYearMin = 1900;
  static int const sc_dateYearMax = 3000;

  // The actual stored data.
  char      m_flightCode[6];
  int       m_numSeats;
  TimeDate  m_time;
	std::string m_destination;
};

} // namespace AirlineRes

#endif //_FLIGHTRECORD_H_20111124
